﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xproject.Util
{
    public class Cache_ComUtil
    {
        public static string CACHE_KEY_UPLOAD_BATCHID = "CACHE_KEY_UPLOAD_BATCHID";

        public static void SetBatchCount(string batchId,int count)
        {
            System.Web.HttpRuntime.Cache.Insert(CACHE_KEY_UPLOAD_BATCHID+ batchId, count, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
        }

        public static int GetBatchCount(string batchId)
        {
            
            var obj= System.Web.HttpRuntime.Cache[CACHE_KEY_UPLOAD_BATCHID+batchId];
            if (obj == null)
            {
                return 1;
            }
            return (int)obj;
        }

        public static void ClearBatchCountInfo(string batchId)
        {
            System.Web.HttpRuntime.Cache.Remove(batchId);
        }
    }
}
